-
Notifications
You must be signed in to change notification settings - Fork 7
LK R&D LKSM - Update default audit level #6945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| { | ||
| void addSummaryAuditEvent(User user, Container c, TableInfo table, QueryService.AuditAction action, Integer dataRowCount, @Nullable AuditBehaviorType auditBehaviorType, @Nullable String userComment); | ||
|
|
||
| default void addSummaryAuditEvent(User user, Container c, TableInfo table, QueryService.AuditAction action, Integer dataRowCount, @Nullable AuditBehaviorType auditBehaviorType, @Nullable String userComment, boolean skipAuditLevelCheck) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There doesn't seem to be any actual usage of the skipAuditLevelCheck. Is this something that can be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used to bypass check for ETL in bulkLoad mode and some other places, it's overriden inAbstractAuditHandler.
|
|
||
| @NotNull | ||
| @Override | ||
| public AuditBehaviorType getDefaultAuditBehavior() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This override looks like it just repeats what TableInfo already specifies. Consider removing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, it actually did mean to override. Fixed.
| setAuditBehavior(auditBehaviorType); | ||
| } | ||
| catch (IllegalArgumentException ignore) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Consider logging a warning about an invalid audit behavior argument here. Same for similar usage in SchemaTableInfo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| { | ||
| for (Long runId: dataChangeCount.keySet()) | ||
| { | ||
| String userComment = configParameters == null ? null : (String) configParameters.get(AuditUserComment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This userComment processing can be moved above the loop.
| Map<String, Object> extraScriptContext | ||
| ) throws InvalidKeyException, BatchValidationException, QueryUpdateServiceException, SQLException | ||
| { | ||
| dataChangeCount = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a LinkedHashMap to retain insertion order so that audit events are consistently added in the same order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| return result; | ||
| } | ||
|
|
||
| private Object lookupDisplayValue(Object o, @NotNull TableInfo fkTableInfo, ColumnInfo fkTablePkCol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice to see this go away.
| @Override | ||
| public AuditBehaviorType getAuditBehavior() | ||
| @NotNull | ||
| public AuditBehaviorType getDefaultAuditBehavior() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should ExpDataClassTableImpl also override this and set to DETAILED?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, ExpDataClassTableImpl is for dataclass type not the data itself. For domains, we have DomainEvent and DomainPropertyEvent.
| } | ||
| else if (tInfo != null) | ||
| { | ||
| ExpSampleType sampleType = SampleTypeService.get().getSampleType(c, tInfo.getUserSchema().getUser(), tInfo.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: No need to call SampleTypeService.get() as this call is being made from within the service itself.
| // NOTE: to avoid a diff in the audit log make sure row("rowid") is correct! (not the unused generated value) | ||
| row.put(ROW_ID,staticsRow.get(ROW_ID)); | ||
| } | ||
| else if (tInfo != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tInfo.getUserSchema() could be null. Consider:
else if (tInfo != null)
{
UserSchema schema = tInfo.getUserSchema();
if (schema != null)
{
ExpSampleType sampleType = getSampleType(c, schema.getUser(), tInfo.getName());
if (sampleType != null)
{
event.setSampleType(sampleType.getName());
event.setSampleTypeId(sampleType.getRowId());
}
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Rationale
Currently, the logic to determine the effective audit behavior is: XML metadata override > API param > table’s default setting (which currently is NONE). With this story, the logic is now updated to Max(xml??tableDefault, api)’s priority. Additionally, the default behavior for samples, dataclass data and assay results are updated to DETAILED. Note that for assay results, the detailed audit logging currently only applies for update/delete actions done using QUS.
Related Pull Requests
Changes